<?php
/**
 * Magento
 *
 * NOTICE OF LICENSE
 *
 * This source file is subject to the Academic Free License (AFL 3.0)
 * that is bundled with this package in the file LICENSE_AFL.txt.
 * It is also available through the world-wide-web at this URL:
 * http://opensource.org/licenses/afl-3.0.php
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@magentocommerce.com so we can send you a copy immediately.
 *
 * DISCLAIMER
 *
 * Do not edit or add to this file if you wish to upgrade Magento to newer
 * versions in the future. If you wish to customize Magento for your
 * needs please refer to http://www.magentocommerce.com for more information.
 *
 * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
 * @license     http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
 */

/**
 * Install download choice template
 *
 * @see \Magento\Install\Block\Download
 */
?>
<script type="text/javascript">
require([
    'prototype'
], function(){

    startInstall = function(state)
    {
        $$('button').each(function(el) {
            el.disabled = true;
            el.addClassName('disabled');
        });
        var install = $('install_iframe');
        install.setStyle({'display':'block', 'width':'100%', 'height':'300px'});
        install.src = '<?php echo $this->getUrl('*/*/install') ?>do/start/state/'+state;
    }

    installSuccess = function()
    {
        alert("<?php echo __("All packages were installed. Click 'OK' to continue with installation.") ?>");
        location.href = "<?php echo $this->getNextUrl() ?>";
        $$('button').each(function(el) {
            el.disabled = true;
            el.removeClassName('disabled');
        });
    }

    installFailure = function()
    {
        alert("<?php echo __("Something went wrong installing the Magento packages. Please read the log, correct any errors and try again.") ?>\n<?php echo __('As another option, you could try the "Manual Downloads and Upgrades" method.') ?>");
        $$('button').each(function(el) {
            el.disabled = true;
            el.removeClassName('disabled');
        });
    }


});
</script>
<div class="page-head">
    <h3><?php echo __('Download Magento Core Modules and Updates') ?></h3>
</div>
<?php echo $this->getLayout()->getMessagesBlock()->getGroupedHtml() ?>

<form action="<?php echo $this->getPostUrl() ?>" method="post" id="form-validate">
<input type="hidden" id="continue" name="continue" value="svn" />
<?php if($this->hasLocalCopy()): ?>
<fieldset class="group-select">
    <legend><?php echo __('Full Download / SVN Installation') ?></legend>
    <h4 class="legend"><?php echo __('Full Download / SVN Installation') ?></h4>

    <p><?php echo __("If you have downloaded the full package or installed Magento through SVN, you should skip packages installation and validation by clicking the button below.") ?></p>

    <p><button class="form-button" type="submit" onclick="$('continue').value='svn'"><span><?php echo __('Continue Full Download / SVN Installation') ?></span></button></p>
</fieldset>
<?php endif; ?>

<fieldset class="group-select">
    <legend><?php echo __('Package Management through the Web') ?></legend>
    <h4 class="legend"><?php echo __('Package Management through the Web') ?></h4>

    <p><?php echo __("If you wish to manage Magento packages through the web admin interface, you will need to have web writeable permissions applied to all Magento folders and files.") ?></p>
    <p><?php echo __("If your server is running on MS Windows, most probably you will not need to change anything.") ?></p>
    <p><?php echo __("If you are running PHP as CGI, your PHP processes may run under the same user as the user you used when uploading Magento files.") ?></p>
    <p><?php echo __("In other cases you will need to make Magento files writeable for the user that the web server process is running under.") ?></p>

        <h4><?php echo __("Preferred stability: %1", __("BETA")) ?></h4>
        <p><?php echo __("This is the most stable state available for Magento packages.") ?><br/><?php echo __("Choose this if you would like to test storefront and admin functionality.") ?></p>
        <p><button class="form-button" type="button" onclick="startInstall('beta')"><span><?php echo __('Proceed With Automatic Download (%1)', __('Beta')) ?></span></button></p>
<br/>
        <h4><?php echo __("Preferred stability: %1", __("ALPHA")) ?></h4>
        <p><?php echo __("If you are a developer and would like to have the latest public updates, choose this option.") ?><br/><?php echo __("Please note that it is much less stable than beta.") ?></p>
        <p><button class="form-button" type="button" onclick="startInstall('alpha')"><span><?php echo __('Proceed With Automatic Download (%1)', __('Alpha')) ?></span></button></p>
<br/>
    <iframe id="install_iframe" src="<?php echo $this->getUrl('*/*/install') ?>" style="display:none" frameborder="no"></iframe>
</fieldset>

<fieldset class="group-select">
    <legend><?php echo __('Manual Downloads and Upgrades') ?></legend>
    <h4 class="legend"><?php echo __('Manual Downloads and Upgrades') ?></h4>

    <p><?php echo __("If you are running the install wizard over a previously downloaded and installed Magento installation, proceed with this method.") ?></p>
    <p><?php echo __("If you do not wish or are not able to have Magento folders writeable for the web process, you could use PEAR executable located in the root of Magento installation.") ?></p>
    <p><?php echo __("Please note that only UNIX, Linux and Mac OS X shells are currently supported. For Windows use the '%1' option.", __('Package Management through the Web')) ?></p>
    <p><?php echo __("Run this in your shell from Magento root folder:") ?></p>
    <pre>
./pear mage-setup
./pear install mage-core/\Magento\Pear_Helpers mage-core/Lib_ZF mage-core/Lib_Varien
./pear install mage-core/Magento_All mage-core/Interface_Install_Default
./pear install mage-core/Interface_Frontend_Default mage-core/Interface_Adminhtml_Default

</pre>
    <p><?php echo __("Click the button below when the installation is finished.") ?></p>

    <p><button class="form-button" type="submit" onclick="$('continue').value='manual'"><span><?php echo __('Continue After Manual Download') ?></span></button></p>
</fieldset>

</form>

<script type="text/javascript">
require(['prototype'], function(){

    tabs = new Varien.Tabs('.tabs');

});
</script>
